package com.superm.service.impl;

import com.superm.entity.MemberLeve;
import com.superm.mappers.MemberLeveMapper;
import com.superm.service.MemberLeveService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MemberLeveServiceImpl implements MemberLeveService {

    @Autowired
    private MemberLeveMapper MemberLeveMp;


    @Override
    public List<MemberLeve> selectMemberLeveList() {
        return MemberLeveMp.selectAll();
    }

    @Override
    public List<MemberLeve> selectLikeMemberLeveList(MemberLeve memberLeve, Integer pageNo, Integer pageSize) {
        return MemberLeveMp.allMemberLeve(memberLeve,(pageNo-1)*pageSize,pageSize);
    }

    /**
     * 实现根据id查找会员分类信息
     * @param memberLeveId
     * @return
     */
    @Override
    public MemberLeve selectIdMem(Integer memberLeveId) {
        return MemberLeveMp.selectMemberLeveId(memberLeveId);
    }

    /**
     * 实现查询总条数
     * @param memberLeve
     * @return
     */
    @Override
    public int selectMemberLeveCount(MemberLeve memberLeve) {
        MemberLeve memberLeve1 = new MemberLeve();
        //将代替类的值获取过来
        BeanUtils.copyProperties(memberLeve,memberLeve1);
        return MemberLeveMp.selectCount(memberLeve1);
    }

    /**
     * 实现修改会员卡分类信息
     * @param memberLeve
     * @return
     */
    @Override
    public int updateMemberLeve(MemberLeve memberLeve) {
        MemberLeve memberLeve1 = new MemberLeve();
        //将代替类的值获取过来
        BeanUtils.copyProperties(memberLeve,memberLeve1);
        return MemberLeveMp.updateInfoMemberLeve(memberLeve1);
    }

    /**
     * 实现添加供应商信息
     * @param memberLeve
     * @return
     */
    @Override
    public int addMemberLeve(MemberLeve memberLeve) {
        MemberLeve memberLeve1 = new MemberLeve();
        //将代替类的值获取过来
        BeanUtils.copyProperties(memberLeve,memberLeve1);
        return MemberLeveMp.addInfoMemberLeve(memberLeve1);
    }

    /**
     * 实现删除会员卡分类信息
     * @param memberLeveId
     * @return
     */
    @Override
    public int deleteMemberLeve(Integer memberLeveId) {
        return MemberLeveMp.deleteInfoMemberLeve(memberLeveId);
    }
}
